package com.Hsu.blog.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.Arrays;
import java.util.List;

/**
 * @author Hsu琛君珩
 * @ClassName:WebConfig
 * @date 2024-01-25
 * @apiNote
 * @Version: v1.0
 */

@Configuration
public class WebConfig implements WebMvcConfigurer {
    private static final List<String> excludePath= Arrays.asList(
            "/user/login",
            "/**/*.html",
            "/pic/**",
            "/js/**",
            "/css/**",
            "/blog-editormd/**"
    );
    @Autowired
    private LoginInterceptor loginInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor).addPathPatterns("/**")//拦截所有路径
                .excludePathPatterns(excludePath);//除了这些路径
    }
}
